<?php

namespace App\Console\Commands;

use App\Jobs\TransferJob;
use Illuminate\Console\Command;

class Transfer extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'app:transfer';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Command description';

    /**
     * Execute the console command.
     */
    public function handle()
    {
        if(!getenv('DOGE_RPC_URL') || !getenv('DOGE_RPC_USER') || !getenv('DOGE_RPC_PASSWORD')){
            return;
        }
        $mints = Mint::where('status', 'waiting')->whereNull('hash')->get();

        foreach ($mints as $mint) {
            if (!$mint->user->address) {
                continue;
            }
            TransferJob::dispatch($mint)->onQueue('transfer');
        }
    }
}
